package com.itheima.mp.controller;


import com.itheima.mp.domain.vo.AddressVO;
import com.itheima.mp.result.Result;
import com.itheima.mp.service.IAddressService;
import com.itheima.mp.service.impl.AddressServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 顾清言
 * @since 2024-05-11
 */
@RestController
@RequestMapping("/address")
@Api(tags = "地址接口")
@Slf4j
public class AddressController {

    @Autowired
    private IAddressService addressService;

    /**
     * 根据用户id查询地址列表
     * @param userId
     * @return
     */
    @GetMapping("/user/{userId}")
    @ApiOperation("根据用户id查询地址列表")
    public Result<List<AddressVO>> getByUserId(@PathVariable Long userId){
        return Result.success(addressService.getByUserId(userId));
    }

}
